
#Title[dʏ]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png"; 
    let imgBoss2 =csd ~ "..\lib/dot_daiyousei2.png"; 
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=42*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	//SetShotAutoDeleteClip(16,32,16,32);
        SetLife(2700);
	InitializeAction();
	SetEnemyMarker(true);
	SetX(GetClipMaxX+16);
	SetY(GetCenterY-0);
        TMainGrobal;
    }

    @MainLoop {
	SetCommonData("BossLife",GetLife);
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }

    @DrawLoop {
//DrawText(GetLife,120,382,12,255);//NԂ̕\
	DrawBoss( imgBoss );
    }

    @Finalize {
	DeleteAllEnemyWithoutBoss;
	SetCommonData("BossX",GetX);
	SetCommonData("BossY",GetY);
	SetCommonData("BossLife",GetLife);
	DeleteEnemyShotToItem(ALL);
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

	SetCommonData("VanishSignal",false);
	SetCommonData("TimeBonus",TimeCounter/StandardTimeCounter);
	SetCommonData("BossRate",10000);
    }

    // C^XN
task TMainGrobal
{
	yield;
	Particle;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(0,250,154);
	BossShadowAnimation(imgBoss2,0,0,250,154);
	standBy;
	DamageRateChange;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}

}

sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni-96, yIni+48,30,8);
	wait(60);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	wait(60);
	summon;
	Concentration01(30);
	//Concentration03(GetX,GetY,60,0,64,255);
}

task Collision
{
	loop(150)
	{
        SetCollisionA(GetX, GetY, 48);
	yield;
	}

	loop
	{
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 16);
	yield;
	}
}

task DamageRateChange
{
loop
{
	if(GetEnemyNum==3){DamageRate=100;}
	else if(GetEnemyNum==2){DamageRate=110;}
	else if(GetEnemyNum==1){DamageRate=120;}
yield;
}
}

task summon
{
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, 1);
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, -1);
}

task TMove
{
loop
{
//	SetMovePosition03(GetX+rand(-10,10), GetY+rand(-10,10), 20,5);
	wait(60);
}
}


task Particle
{
loop
{
ParticleEffect;
wait(5);
}
}

task ParticleEffect
{
		let obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd~"..\img\ParticleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -8, -8);
		ObjEffect_SetVertexXY(obj, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj, 2, 8, 8);
		ObjEffect_SetVertexXY(obj, 3,  -8,  8);

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16, 0);
		ObjEffect_SetVertexUV(obj, 2, 16,  16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);
		let Alpha=100;
		let StandardAlpha=Alpha;
		let R;let G;let B;
		R=0;G=255;B=0;
		ObjEffect_SetLayer(obj,1);
		Obj_SetPosition(obj,GetX+rand(-20,20),GetY+rand(-20,20));
		let speed=rand(0.5,1.0);
		let angle=rand(88,92);
		let Scale=0.5;
		let StandardScale=Scale;
		if(GetCommonDataDefault("LightMode_BossBlur",0)==1){Obj_Delete(obj);return;}
		loop(30)
		{
			Alpha-=StandardAlpha/30;
			Scale-=StandardScale/30;
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(angle),Obj_GetY(obj)+speed*sin(angle));
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			yield;
		}
		Obj_Delete(obj);
}

task shotM
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	kunaishot(GetAngleToPlayer,73,looptime);
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..15)
	{
		CreateShot01(GetX,GetY,3+0.3*i,90,73,5);
		wait(3);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

task kunaishot(let angle,let color,looptime)
{
	loop(8)
	{
		ascent(let i in -(looptime+1)..looptime+2)
		{
			CreateShot01(GetX,GetY,3.5,angle+(30-5*looptime)*i,73,5);
		}
	wait(3);
	}
}

}
/////////////////////////////////////////////////////////////////////////////
task shotE
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	let angle=rand(0,360);
	ascent(let j in 0..8+looptime*2)
	{
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3.0,angle+i*30+j*1.5,73,5);
		}
	}
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..9)
	{
		CreateShot02(GetX,GetY,1,rand(60,120),0.05,5,73,5);
		wait(5);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

}
//////////////////////////////////////////////////////////////////////
task shotA
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	kunaishot(GetAngleToPlayer,RED31);
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..15)
	{
		CreateShot01(GetX,GetY,3+0.4*i,90,73,5);
		CreateShot01(GetX,GetY,3+0.4*i,45,73,5);
		CreateShot01(GetX,GetY,3+0.4*i,120,73,5);
		wait(3);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

task kunaishot(let angle,let color)
{
	loop(5)
	{
	ascent(let i in -(looptime+2)..looptime+3)
	{
	CreateShot01(GetX,GetY,5,angle+i*(15-looptime*2),73,5);
	}
	wait(3);
	}
}

}

#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Daiyousei.txt"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(500);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
        yield;

    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,10,0.3);

	if(GetCommonDataDefault("BossLife",0)>0)
	{
		loop(5)
		{
			FinalizeItemSet(1);
		}
	}
	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition02(100*num, 0, 30);
	wait(30);
	let X=100*num;
	let Y=0;
	loop(365)
	{
	SetX(X);
	SetY(Y);
	yield;
	}
	SetAngle(GetAngleToPlayer);
	let speed=0;
	loop
	{
		SetSpeed(speed);
		speed+=0.1;
		yield;
		if(GetY>GetClipMaxY+32){VanishEnemy;}
	}

}

task shotM
{
wait(30);
loop(4)
{
let angle=GetAngleToPlayer;
ascent(let i in -3..4)
{
CreateShot01(GetX,GetY,3,angle+i*1.5,14,5);
}
wait(60);
}
wait(20);
let angle=rand(0,360);
ascent(let i in 0..12)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*30,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,4.5,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,4.25,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,4.0,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,3.75,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,3.5,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.25,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.0,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);

FireShot(0);
}
wait(60);

ascent(let i in 0..15)
{
	CreateShot01(GetX,GetY,3+0.3*i,90,78,5);
	wait(3);
}

}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);
wait(15+num*15);
loop(4)
{
let angle=GetAngleToPlayer;
loop(10)
{
CreateShot01(GetX,GetY,5,angle,78,5);
wait(3);
}
wait(30);
}
wait(15-num*15);
let angle=rand(0,360);
ascent(let i in 0..24)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*15,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,4,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,3.75,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,3.5,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,3.25,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,3,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,2.75,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,2.5,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);
FireShot(0);
}
wait(50);

ascent(let i in 0..9)
{
	CreateShot02(GetX,GetY,1,rand(60,120),0.05,5,78,5);
	wait(5);
}

}
////////////////////////////////////////////////////////////
task shotA
{
wait(30);
loop(4)
{
	let angle=rand(0,360);
	ascent(let j in 0..11)
	{
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3.0,angle+i*30+j*1.5,78,5);
		}
	}
wait(60);
}
wait(20);
let angle=rand(0,360);
ascent(let i in 0..36)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*10,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,5,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,4.75,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,4.5,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,4.25,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,4,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.75,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.75,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);

FireShot(0);
}
wait(60);

ascent(let i in 0..15)
{
	CreateShot01(GetX,GetY,3+0.4*i,90,78,5);
	//CreateShot01(GetX,GetY,3+0.4*i,60,78,5);
	CreateShot01(GetX,GetY,3+0.4*i,45,78,5);
	CreateShot01(GetX,GetY,3+0.4*i,120,78,5);
	//CreateShot01(GetX,GetY,3+0.4*i,135,78,5);
	wait(3);
}

}
    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

#include_script ".\..\txt/EnemyShotData.txt"
